package com.jiazhong.basic.shuxin.thread;

import lombok.SneakyThrows;

public class DemoD2 {

//    @SneakyThrows
//    public synchronized void a() {
//        String currentThreadName = Thread.currentThread().getName();
//        System.out.println(currentThreadName + "准备执行代码a");
//        Thread.sleep(10000);
//        System.out.println(currentThreadName + "结束执行代码a");
//    }

    @SneakyThrows
    public void a() {
        String currentThreadName = Thread.currentThread().getName();
        System.out.println(currentThreadName + "开开心心去执行");
        synchronized (this) {
            System.out.println(currentThreadName + "准备执行代码a");
            Thread.sleep(10000);
            System.out.println(currentThreadName + "结束执行代码a");
        }
    }
}
